home *** CD-ROM | disk | FTP | other *** search
/ Inventor Labs: Technology / INVENTORLABS_TECHNOLOGY.BIN / pc / files / invest.dir / 00385_Script_Inv Resistance Object < prev    next >
Text File  |  1997-05-26  |  7KB  |  234 lines

  1. --Inv Resistance Object
  2.  
  3. property pCurrent, pCurrentFactor, pLightFactor, pLength, pCutoff, pPuppetSpriteList
  4. property pResist, pSoundlist, pWireStartSprite, pDiameter, pType, pFactor
  5. property pLastHighestLight, pLights, pFirstLightCastNum, pFirstShaftCastNum
  6.  
  7. -- tj&dl
  8. property pNewWire, pOldWire
  9. property pGlow, pLastGLow
  10. property pNewGlow, pDot, pNewGlow2
  11. property pStartCommentMem
  12.  
  13. ---------------------------------------------------------------ò
  14. on mInit me
  15.   set pPuppetSpriteList = [3,4,5,18,19,20,23,24,25,21,22,31]
  16.   set pResist = [.000147,.35,.000172,.001]
  17.   set pSoundlist = [the number of cast "IREFLUC1.AIF", the number of cast "IREFLUE1.AIF", the number of cast "IREFLUG1.AIF", the number of cast "IREFLUC2.AIF", the number of cast "IREFLUE2.AIF", the number of cast "IREFLUG2.AIF"]
  18.   set pFirstLightCastNum = the number of cast "IREGRL1.PIC"
  19.   set pFirstShaftCastNum = the number of cast "IRECPWS.PIC"
  20.   --put "pSoundlist at mInit" && pSoundList
  21.   set pWireStartSprite = 6
  22.   set pGlow = 2 -- the sprite channel with the glowing thingy
  23.   set pLastGLow = the number of cast "glow.pics00067" -- last in the sequence
  24.   
  25.   set pNewGlow = member "glow1.pic.8bit"
  26.   set pNewGlow2 = member "glow2.pic.8bit"
  27.   set pDot = member "Dot"
  28.   set pStartCommentMem =  the number of member "OUTCOME 1"
  29.   return me
  30. end mInit
  31. ---------------------------------------------------------------ò
  32. on mActivate me
  33.   
  34.   repeat with x in pPuppetSpriteList
  35.     puppetSprite x,true
  36.   end repeat
  37.   
  38.   set the immediate of sprite 4 to true
  39.   
  40.   --set lights to list(6)
  41.   set pLights = [6]
  42.   set pType = 1
  43.   set pDiameter = 2
  44.   
  45.   -- tj&dl
  46.   set pNewWire = #DEFAULT
  47.   set pOldWire = #DEFAULT
  48.   set the puppet of sprite pGlow = 1
  49.   
  50. end mActivate
  51. ---------------------------------------------------------------ò
  52. on mClose me
  53.   repeat with x in pPuppetSpriteList
  54.     puppetSprite x,false
  55.   end repeat
  56.   
  57.   if not(pNewWire = #DEFAULT) then set the visible of sprite pNewWire = TRUE
  58.   if not(pOldWire = #DEFAULT) then set the visible of sprite pOldWire = TRUE
  59.   
  60.   set the puppet of sprite pGlow = 0
  61.   
  62.   --tj&dl
  63.   repeat with n = 2 to 20
  64.     set the puppet of sprite n = 0
  65.     set the visible of sprite n = 1
  66.   end repeat
  67.   puppetsprite 33,  false
  68. end mClose
  69. ---------------------------------------------------------------ò
  70. on mCalcFactors me
  71.   
  72.   -- set light display according to value of current
  73.   -- because the range is so large, we take the log of the current
  74.   -- the factors are used to create 6 current levels (1-6),and
  75.   -- four light levels for each current level  
  76.   -- check to see if there is current  
  77.   --put "pCurrent" && pCurrent
  78.   if pCurrent <> 0 then
  79.     set tempcurrentFactor = .476*log(pCurrent)+1.89
  80.     set pCurrentFactor = integer(tempcurrentFactor+.5)
  81.     -- determine value of variable light
  82.     set pLightFactor = integer(3*(tempcurrentFactor-pCurrentFactor+1))    
  83.   else 
  84.     set pCurrentFactor = -1  
  85.     --put current&&tempcurrentFactor&¤tFactor&& pLightfactor
  86.   end if
  87.   --\
  88.   --  put "We are at the end of mCalcFactors"
  89.   --  put "tempcurrentFactor = " & tempcurrentFactor
  90.   --  put "pCurrentFactor" & pCurrentFactor
  91.   --  put "pLightFactor" & pLightFactor
  92.   
  93. end mCalcFactors
  94. ---------------------------------------------------------------ò
  95. on mMoveSlider me
  96.   repeat while the mousedown
  97.     set x = mouseH() - (mouseH() mod 3)
  98.     
  99.     --set x = mouseH()
  100.     if x < 219 then set x = 219
  101.     if x > 370 then set x = 370
  102.     
  103.     set the loch of sprite 4 to x
  104.     set the width of sprite 5 to 446-x
  105.     set the loch of sprite 5 to integer(333+((x-219)/2))
  106.     --set pLength = x - 219
  107.     set pLength = x - 221
  108.     
  109.     set GlowIndex = ((pLength - 5) / 2.44) + 5
  110.     set the castNum of sprite pGlow = pLastGLow - GlowIndex
  111.     if GlowIndex < 60 then
  112.       set the member of sprite 21 = pNewGlow
  113.       set the member of sprite 22 = pNewGlow2
  114.     else
  115.       set the member of sprite 21 = pDot
  116.       set the member of sprite 22 = pDot
  117.     end if
  118.     
  119.     
  120.     set pCutoff = 1
  121.     if pLength < 1 then set pLength = 1
  122.     if pLength > 141 then
  123.       set pLength = 141
  124.       set pCutoff = 0
  125.     end if
  126.     mChangelight(me)
  127.     updateStage
  128.   end repeat
  129. end mMoveSlider
  130. ---------------------------------------------------------------ò
  131. on mChangeLight me
  132.   -- set conversion factor
  133.   set pFactor = 1  
  134.   
  135.   set pCurrent = pCutoff*pFactor/((getAt(pResist,pType)*(pLength+10)/(pDiameter*pDiameter)))  
  136.   
  137.   -- determine pCurrentand light factors
  138.   mCalcFactors me
  139.   
  140.   -- set pCurrenthighest lit light
  141.   set highestLight = 1
  142.   
  143.   -- set values of individual lights
  144.   -- determine bottom three lights first
  145.   repeat with x = 1 to 3
  146.     if x < pCurrentFactor then
  147.       set lightvalue = 4
  148.     else
  149.       if x = pCurrentFactor then
  150.         set lightvalue = 1+ pLightFactor
  151.         set highestlight = x
  152.       else
  153.         set lightvalue = 0
  154.       end if
  155.     end if
  156.     
  157.     setAt(pLights,x,lightvalue)
  158.   end repeat
  159.   
  160.   -- determine light values for next 2 higher lights
  161.   
  162.   repeat with x = 4 to 5
  163.     --put "pCurrentFactor" && pCurrentFactor
  164.     if x < pCurrentFactor then
  165.       set lightvalue = 8
  166.     else
  167.       if x = pCurrentFactor then
  168.         set lightvalue = 5+ pLightFactor
  169.         set highestlight = x
  170.       else
  171.         set lightvalue = 0
  172.       end if
  173.     end if
  174.     setAt(pLights,x,lightvalue)
  175.   end repeat
  176.   
  177.   -- determine top light value
  178.   set x = 6
  179.   if x < pCurrentFactor then
  180.     set lightvalue = 12
  181.   else
  182.     if x = pCurrentFactor then
  183.       set lightvalue = 9+ pLightFactor
  184.       set highestlight = x
  185.     else
  186.       set lightvalue = 0
  187.     end if
  188.   end if
  189.   setAt(pLights,x,lightvalue)
  190.   
  191.   -- check to see if a different light is the current highest light
  192.   if pLastHighestLight <> highestlight then
  193.     puppetSound 1, getAt(pSoundList, highestLight)
  194.     set pLastHighestLight = highestLight
  195.   end if
  196.   
  197.  
  198.  
  199. set CommentMem = pStartCommentMem + (pLastHighestLight - 1)
  200.   
  201.   if getAt (pLights,1) = 0 then set CommentMem = pDot
  202.   set the member of sprite 31 = member CommentMem
  203.   
  204.   
  205.   --sprite channel allocations are no longer contiguous -tj
  206.   set the castnum of sprite 25 to pFirstLightCastNum + (getAt (pLights,6))
  207.   set the castnum of sprite 24 to pFirstLightCastNum + (getAt (pLights,5))
  208.   set the castnum of sprite 23 to pFirstLightCastNum + (getAt (pLights,4))
  209.   set the castnum of sprite 20 to pFirstLightCastNum + (getAt (pLights,3))
  210.   set the castnum of sprite 19 to pFirstLightCastNum + (getAt (pLights,2))
  211.   set the castnum of sprite 18 to pFirstLightCastNum + (getAt (pLights,1))
  212.   
  213.   put "pLights" && pLights
  214. end mChangeLight
  215. ---------------------------------------------------------------ò
  216. on mChangeCast me
  217.   set pOldWire = pNewWire
  218.   set pNewWire = the clickOn
  219.   if pOldWire = #DEFAULT then 
  220.     set the visible of sprite pNewWire = FALSE
  221.   else
  222.     set the visible of sprite pOldWire = TRUE
  223.     set the visible of sprite pNewWire = FALSE
  224.   end if
  225.   
  226.   set pType = (the clickOn - pWireStartSprite + 3) / 3
  227.   set pDiameter = ((the clickOn - pWireStartSprite + 3) mod 3) + 1
  228.   set temp = (pType-1)*3 + pDiameter + pFirstShaftCastNum - 1
  229.   put "temp" && temp
  230.   set the castnum of sprite 3 to temp
  231.   updateStage
  232.   mChangelight(me)
  233. end mChangeCast
  234. ---------------------------------------------------------------ò